package com.mohe.shanpao.utils;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

public class CommonUtils {
	
	public static String generateSalt()
	{
        return new SecureRandomNumberGenerator().nextBytes().toHex();
	}
	
	public static String generatePassword(String password,String salt,String algorithmName)
	{
        int hashIterations = 2;
        SimpleHash hash = new SimpleHash(algorithmName, password, salt, hashIterations);
        return hash.toHex();
	}
	
	public static void main(String[] args)
	{
//		System.out.println(generateSalt());
		System.out.println(generatePassword("123", "zhang7caaa0176b8cf70fbc2cdcb4f977f999", Constants.DEAFULT_ALGORITHM_NAME));
	}
}
